package projet;

import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.Border;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import java.awt.Color;
import java.awt.Graphics;


public class Panneau extends JPanel {
	private String chemin= "";
	private Border bordure = BorderFactory.createBevelBorder(1, Color.BLACK, Color.WHITE);
	
	Panneau(){
		super();
		this.setBorder(bordure);
	}
	Panneau(Color c){
		this.setBackground(c);
		this.setBorder(bordure);
	}
	Panneau(String chemin){
		this.chemin= chemin;
	}

	public void paintComponent(Graphics g){
		super.paintComponent(g);
		if(this.chemin != "")
		{
			try {
					Image img = ImageIO.read(new File(chemin));
					g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), this);
		    } 
			catch (IOException e) {
		      e.printStackTrace();
			}  
		}
	}
}
